import Vue from 'vue'
import VueRouter from 'vue-router';
import { routes, menuroutes } from './routes.js'
import { isAuth } from '@/utils/auth'



Vue.use(VueRouter);



const router = new VueRouter({
    mode: 'history',
    routes: routes.concat(menuroutes) //因为routes.js文件中若以数据形式追加菜单栏menuroutes[0]路由数据会识别不了，只能现成合并了
})
router.beforeEach((to, from, next) => {
    let isAuthenticated = isAuth();
    if (to.path !== '/login' && !isAuthenticated) next('/login')
    else next()
})

export default router